package com.kateba.android.hid;

public class KBRep
{
  final int KB_REPEAT_RATE = 400;
  final int KB_REPEAT_STARTDELAY = 700;
  Thread m_Thread = null;
  int m_dwKBRep_Speed = 0;
  long m_dwKBRep_Time = 0L;
  int m_nKBRep_Code = 0;
  Action m_pobjAction = null;

  KBRep(Action paramAction)
  {
    if (paramAction != null)
      this.m_pobjAction = paramAction;
  }

  public void DeinitRep()
  {
    this.m_nKBRep_Code = 0;
    this.m_dwKBRep_Time = 0L;
    this.m_dwKBRep_Speed = 0;
    this.m_Thread = null;
  }

  public int GetLastRepCode()
  {
    return this.m_nKBRep_Code;
  }

  void InitRep(int paramInt)
  {
    this.m_dwKBRep_Speed = 0;
    this.m_nKBRep_Code = paramInt;
    this.m_dwKBRep_Time = System.currentTimeMillis();
    if (this.m_Thread == null)
    {
      this.m_Thread = new Thread()
      {
        public void run()
        {
          while (true)
          {
            if (KBRep.this.m_nKBRep_Code == 0)
              label10: return;
            try
            {
              sleep(400 - KBRep.this.m_dwKBRep_Speed);
              if ((KBRep.this.m_nKBRep_Code == 0) || (System.currentTimeMillis() - KBRep.this.m_dwKBRep_Time <= 700L))
                continue;
              if (KBRep.this.m_pobjAction == null)
            //    break label10;
              KBRep.this.m_pobjAction.SendKey(KBRep.this.m_nKBRep_Code, 0);
              if (KBRep.this.m_dwKBRep_Speed >= 320)
                continue;
              KBRep localKBRep = KBRep.this;
              localKBRep.m_dwKBRep_Speed = (35 + localKBRep.m_dwKBRep_Speed);
            }
            catch (InterruptedException localInterruptedException)
            {
              while (true)
                localInterruptedException.printStackTrace();
            }
          }
        }
      };
      this.m_Thread.start();
    }
  }
}